{% extends 'ProjResManBundle::layout.html.twig' %}

{% block header_menu_login_href %}{% if template_content.auth.isAuth == false %}{{ template_content.header.menu.login }}{% else %}{{ template_content.header.menu.logout }}{% endif %}{% endblock %}
{% block header_menu_login_text %}{% if template_content.auth.isAuth == false %}{{ template_content.header.text.login }}{% else %}{{ template_content.header.text.logout }}{% endif %}{% endblock %}
{% block header_menu_login_user %}{% if template_content.auth.isAuth == true %}{{ template_content.auth.user }}{% endif %}{% endblock %}
{% block header_menu_login_message %}{% if template_content.auth.isAuth == true %}User:{% endif %}{% endblock %}
{% block content %}
<div id="page_content">
    <div id="submenu">
        <div id="submenu_float1">
            <div id="submenu_float2">
                <ul>
                    {% block submenu -%}
                    {% for item in template_content.content.submenu %}
                    <ul class="submenu_option">
                        <a href={{ item.href }}>
                        <li class="submenu_header">{{ item.title }}</li>
                        <li class="submenu_details">{{ item.title_desc }}</li>
                    </a>
                    </ul>
                    {% endfor %}
                    {% endblock %}
                </ul>
            </div>
        </div>
    </div>
        
    <div id="container">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>Denumire</th>
                    <th>Descriere</th>
                    <th>Data inceperii</th>
                    <th>Data finalizarii</th>
                    <th>Departament</th>
                </tr>
            </thead>
            <tbody>
                {% for project in projects %}
                    <tr>
                        <td>{{ project.name }}</td>
                        <td>{{ project.description}}</td>
                        <td>{{ project.startDate.format('Y-m-d') }}</td>
                        <td>{{ project.endDate.format('Y-m-d') }}</td> 
                        <td>{{ project.department }}</td>
                        <td>
                            <a href="javascript: SetVisible('content_{{project.id}}');">
                                <button type="button" class="btn btn-info">
                                    Activitati
                                </button>
                            </a>
                        </td>
                   </tr>
                   <tr>
                        <td colspan="10" > 
                            <div id="content_{{project.id}}" style="display: none">
                                {% if project.activities|length == 0 %}
                                    Nu exista activitati pentru acest proiect.
                                {% else %}
                                <table class="table table-hover">
                                    <thead>
                                        <tr>
                                            <th>Nume</th>
                                            <th>Data crearii</th>
                                            <th>Tipul</th>
                                            <th>Nr. de ore</th>
                                            <th>Data inceperii</th>
                                            <th>Data finalizarii</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {%for activity in project.activities %}
                                            <tr>
                                                <td>{{ activity.name }}</td>
                                                <td>{{ activity.creationDate.format('Y-m-d') }}</td>
                                                <td>{{ activity.type }}</td> 
                                                <td>{{ activity.hours }}</td>
                                                <td>{{ activity.startDate.format('Y-m-d') }}</td>
                                                <td>{{ activity.endDate.format('Y-m-d') }}</td>
                                            </tr>
                                        {% endfor %}
                                    </tbody>
                                </table> 
                                {% endif %}
                            </div>   
                        </td>
                    </tr>
               {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}